import TableData from "@/components/public/el-table-pagination"; //主页面列表
import TableLyout from '@/components/commonPublic/tableLyoutDetail.vue'
import tree from "@/components/PhysicalQualityPage/reboundStrengthManage/tree"; //左侧机构树
import CustomDialog from "@/components/PhysicalQualityPage/reboundStrengthManage/reboundDetectionData/index.vue";
import publicForm from "@/components/materialDataManage/fromCom.vue"; //弹框form
import formJs from "./regexDetail.js"; //新增弹框配置
import CustomDialogs from "@/components/PhysicalQualityPage/reboundStrengthManage/reboundDetectionTask/index.vue";
import CustomDialog2 from "@/components/PhysicalQualityPage/rebarThicknessManage/rebarRecordApproval/index.vue";

import {
    getConcreteCheckSamplePageList, //列表
} from "@/api/request.js";

export default {
    name: "reboundRecordApprovalText",
    data() {
        return {
            name: "reboundRecordApprovalText",
            isLock: false,
            loading: false,
            btnObj: [], //按钮
            queryCriteriaData: {}, //分页
            table_config: formJs.table_config, //列表
            radio: "待办",
            // 列表
            getList: {
                startDates: "", // 开始时间
                endDates: "", // 截至时间
                modelType: "4", // 4待办 5已办 2查询  6内嵌
                userId: "", // 查询待办或已办时传 列表页查询不传
                fCompanyid: "",
                page: 1, // 当前页码
                pageSize: 20, // 每页显示条数
                timeDates: null
            },
            isShow: false, //是否显示弹框
            isShows: false,
            statusNum2: null,//审批流程--是否显示弹框
            isShow2: false, //审批流程--是否显示弹框

            statusNum: null, //点击那个按钮
            dataFid: null, //列表详情id
            currentRow: null, //列表详情
            tableData: [],
            dialogTitle: null,
            treelength: false,
            treeText: {
                companyId: null,
                userId: null,
            },

        };
    },
    components: {
        TableLyout,
        publicForm,
        TableData,
        tree,
        CustomDialog,
        CustomDialogs,
        CustomDialog2
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("yjSmart-userInfo"));
        this.getList = {
            startDates: "", // 开始时间
            endDates: "", // 截至时间
            modelType: "4", // 4待办 5已办 2查询  6内嵌
            userId: this.userInfo.userId,  // 查询待办或已办时传 列表页查询不传
            fCompanyid: this.userInfo.companyId,
            page: 1, // 当前页码
            pageSize: 20, // 每页显示条数
            timeDates: null
        };
        this.yj_searchForm(this.getList);
        this.btnRole(this.name)
        this.table_config.operation.cols = [
            {
                prop: "fStatus",
                type: "primary",
                handleRow: this.handleRow,
            },
        ];
        this.table_config.operation["specialClass"] = function (rowData) {
            var color = null;
            if (rowData == "待检测") {
                color = "red !important";
            } else if (rowData == "检测中") {
                color = "orange !important";
            } else if (rowData == "已完成") {
                color = "green !important";
            } else {
                color = "#409eff !important";
            }
            return color;
        };
    },
    methods: {
        refreshList() { //刷新列表
            this.$nextTick(() => {
                this.yj_searchForm(this.getList);
            })
        },
        closeDialog() {//报告记录编号&审核流程
            this.isShow = false;
            this.isShow2 = false;
        },
        closeDialogs() {//任务编号
            this.isShows = false;
        },
        btnRole(name) {
            if (this.userInfo.userId != 'System') {
                var btnList = [];
                var ModuleList = JSON.parse(sessionStorage.getItem("yjSmart-ModuleList"));
                if (ModuleList.length > 0) {
                    ModuleList.map((item) => {
                        if (item.fEncode == name) {
                            btnList = item.modulebuttonList;
                        }
                    });
                    btnList.map(item => {
                        item['disabled'] = false
                    })
                    this.btnObj = btnList
                }
            } else {
                this.btnObj = formJs.btnObj
            }
        },
        getBtnName(name, status) {
            this.statusNum = status
            this.yj_edit(status)
        },
        // 新增/编辑
        yj_edit(num) {
            if (this.userInfo.userId != "System") {
                if (num == 1) { //审批
                    this.statusNum2 = num;
                    if (this.dataFid != null) {
                        // if (this.currentRow.fStatus == "审核中") {
                        this.editText();
                        // } else {
                        //     this.$message.warning("请选择信息状态为'审核中'的数据！");
                        // }
                    } else {
                        this.$message.warning("请先选择需要审批的数据");
                    }
                }

            } else {
                this.$message.warning("该用户无法操作");
            }
        },
        editText() {
            this.isShow2 = true;
        },

        // 点击查看
        yj_viewForm(row, label) {
            if (label == "报告编号") {
                this.currentRow = row;
                this.statusNum = 7
                this.isShow = true;

            } else if (label == "记录编号") {
                this.currentRow = row;
                this.statusNum = 8
                this.isShow = true;
            } else if (label == "任务编号") {
                this.currentRow = row;
                this.statusNum = 7
                this.isShows = true;
            }
        },
        // 点击当前行变色
        rowChange(val) {
            this.currentRow = val
            this.dataFid = val.fId;
        },
        // 待办/已办
        modelType(e) {
            this.currentRow = "";
            this.dataFid = "";
            if (e == "待办") {
                this.getList.modelType = "4";
            } else {
                this.getList.modelType = "5";
            }
            this.yj_searchForm(this.getList);
        },
        // 获取列表数据
        yj_searchForm(data) {
            var obj = {
                startDates: data.startDates, // 开始时间
                endDates: data.endDates, // 截至时间
                modelType: data.modelType, // 4待办 5已办 2查询
                userId: this.userInfo.userId, // 查询待办或已办时传 列表页查询不传
                fCompanyid: data.fCompanyid,
                page: data.page, // 当前页码
                pageSize: data.pageSize, // 每页显示条数
            }
            this.loading = true;
            getConcreteCheckSamplePageList(obj)
                .then((res) => {
                    if (res.errcode == 0) {
                        var that = this;
                        that.loading = false;
                        that.tableData = res.data.pageInfo.list;
                        that.queryCriteriaData = res.data.pageInfo;
                    } else {
                        this.$message.error("列表", res.msg);
                        this.loading = false;
                    }
                })
                .catch(() => {
                    this.loading = false;
                    console.log("获取列表数据接口报错");
                });
        },

    },
};